{% extends 'base.html' %}
{% load static %}
{% block css %}

{% endblock %}
{% block title %}
任务列表
{% endblock %}
{% block page-title %}
任务列表
{% endblock %}
{% block page-content %}
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">查看任务列表</h3>
            </div>
            <div class="panel-body">
                <div class="row" style="margin-bottom: 5px">
                    <div class="col-md-2" style="float: right">
                        <form class="form-horizontal" role="form">
                            <div class="input-group">
                                <input type="text" id="keyword" name="keyword" class="form-control"
                                    value="{{ keyword|default_if_none:'' }}" placeholder="关键字">
                                <span class="input-group-btn">
                                    <button type="submit" class="btn btn-effect-ripple btn-primary">搜索</button>
                                </span>
                            </div>
                        </form>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <table class="table table-bordered" style="table-layout:fixed;width: 100%">
                            <thead>
                                <tr>
                                    <th style="width: 15%;text-align: center">任务概述</th>
                                    <th style="width: 30%;text-align: center">目标机器</th>
                                    <th style="width: 10%;text-align: center">提交时间</th>
                                    <th style="width: 10%;text-align: center">任务详情</th>
                                    <th style="width: 10%;text-align: center">任务状态</th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for task in object_list %}
                                <tr>
                                    <td style="word-wrap: break-word;width: 25%;text-align: center">{{ task.name }}</td>
                                    <td style="word-wrap: break-word;width: 50%;text-align: center">
                                        {{ task.dest_hosts }}</td>
                                    <td style="word-wrap: break-word;width: 10%;text-align: center">
                                        {{ task.created_at }}</td>
                                    <td style="word-wrap: break-word;width: 5%;text-align: center">
                                        <a href="{% url 'task:task_detail' task.id %}?prev=tasks"
                                            style="color: rgba(0,170,255,0.74)">查看</a>
                                    </td>
                                    <td style="word-wrap: break-word;width: 5%;text-align: center">
                                        <label class="label
                                                    {% if task.status == 0 %}
                                                    label-default
                                                    {% elif task.status == 1 %}
                                                    label-success
                                                    {% elif task.status == 2 %}
                                                    label-danger
                                                    {% endif %}">{{ task.get_status_display }}
                                        </label>
                                    </td>
                                </tr>
                                {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-4">
                        <p style="margin-top: 10px"> 显示 [{{ page_obj.paginator.count }}] 条数据中的 第
                            [{{ page_obj.start_index }}] 至 [{{ page_obj.end_index }}] 的数据</p>
                    </div>
                    <div class="col-md-8">
                        {% if page_obj.paginator.num_pages > 1 %}
                        {% include '_paginator.html' %}
                        {% endif %}
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>
{% endblock %}
{% block js %}
<script>
    $('.task').addClass('active');
    $('.task .tasks').addClass('active');
</script>
{% endblock %}